import { useAccess } from 'umi';

export const usePermission = () => {
  const access = useAccess();

  const hasPermission = (permission: string) => {
    return access[permission] === true;
  };

  const hasAnyPermission = (permissions: string[]) => {
    return permissions.some((permission) => access[permission] === true);
  };

  const hasAllPermissions = (permissions: string[]) => {
    return permissions.every((permission) => access[permission] === true);
  };

  return {
    hasPermission,
    hasAnyPermission,
    hasAllPermissions,
  };
}; 
